import java.util.*;

public class Test {
    public static void main(String[] args) {
        ArrayList<String> list=new ArrayList<>();
        list.add("java1");
        list.add("java2");
        list.add("java3");
        list.add("java4");
        list.add("java1");
        /*Object[] arr=list.toArray();
        System.out.println(Arrays.toString(arr));
        String[] arr2=list.toArray(new String[list.size()]);
        System.out.println(Arrays.toString(arr2));*/
        //System.out.println(list);
        /*HashSet<String> set=new HashSet<>();
        set.add("java1");
        set.add("java2");
        set.add("java3");
        set.add("java4");
        set.add("java1");*/
        //set.clear();
       /* set.remove("java1");
        System.out.println(set);*/
        Iterator<String> it=list.iterator();
       /* System.out.println(it.next());
        System.out.println(it.next());
        System.out.println(it.next());
        System.out.println(it.next());
        System.out.println(it.next());*/
        while(it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("-------------------------------");
        for (String x:
             list) {
            System.out.println(x);
            
        }

    }
}
